home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / cvs-1_3.lha / cvs-1.3 / src / no_diff.c < prev    next >
C/C++ Source or Header  |  1992-03-31  |  2KB  |  86 lines

  1. /*
  2.  * Copyright (c) 1992, Brian Berliner and Jeff Polk
  3.  * Copyright (c) 1989-1992, Brian Berliner
  4.  * 
  5.  * You may distribute under the terms of the GNU General Public License as
  6.  * specified in the README file that comes with the CVS 1.3 kit.
  7.  * 
  8.  * No Difference
  9.  * 
  10.  * The user file looks modified judging from its time stamp; however it needn't
  11.  * be.  No_difference() finds out whether it is or not. If it is not, it
  12.  * updates the administration.
  13.  * 
  14.  * returns 0 if no differences are found and non-zero otherwise
  15.  */
  16.  
  17. #include "cvs.h"
  18.  
  19. #ifndef lint
  20. static char rcsid[] = "@(#)no_diff.c 1.35 92/03/31";
  21. #endif
  22.  
  23. int
  24. No_Difference (file, vers, entries)
  25.     char *file;
  26.     Vers_TS *vers;
  27.     List *entries;
  28. {
  29.     Node *p;
  30.     char tmp[L_tmpnam+1];
  31.     int ret;
  32.     char *ts, *options;
  33.     int retcode = 0;
  34.  
  35.     if (!vers->srcfile || !vers->srcfile->path)
  36.     return (-1);            /* different since we couldn't tell */
  37.  
  38.     if (vers->entdata && vers->entdata->options)
  39.     options = xstrdup (vers->entdata->options);
  40.     else
  41.     options = xstrdup ("");
  42.  
  43.     run_setup ("%s%s -p -q -r%s %s", Rcsbin, RCS_CO,
  44.            vers->vn_user ? vers->vn_user : "", options);
  45.     run_arg (vers->srcfile->path);
  46.     if ((retcode = run_exec (RUN_TTY, tmpnam (tmp), RUN_TTY, RUN_REALLY)) == 0)
  47.     {
  48.     if (!iswritable (file))        /* fix the modes as a side effect */
  49.         xchmod (file, 1);
  50.  
  51.     /* do the byte by byte compare */
  52.     if (xcmp (file, tmp) == 0)
  53.     {
  54.         if (cvswrite == FALSE)    /* fix the modes as a side effect */
  55.         xchmod (file, 0);
  56.  
  57.         /* no difference was found, so fix the entries file */
  58.         ts = time_stamp (file);
  59.         Register (entries, file,
  60.               vers->vn_user ? vers->vn_user : vers->vn_rcs, ts,
  61.               options, vers->tag, vers->date);
  62.         free (ts);
  63.  
  64.         /* update the entdata pointer in the vers_ts structure */
  65.         p = findnode (entries, file);
  66.         vers->entdata = (Entnode *) p->data;
  67.  
  68.         ret = 0;
  69.     }
  70.     else
  71.         ret = 1;            /* files were really different */
  72.     }
  73.     else
  74.     {
  75.     error (0, retcode == -1 ? errno : 0,
  76.            "could not check out revision %s of %s", vers->vn_user, file);
  77.     ret = -1;            /* different since we couldn't tell */
  78.     }
  79.  
  80.     if (trace)
  81.     (void) fprintf (stderr, "-> unlink(%s)\n", tmp);
  82.     (void) unlink (tmp);
  83.     free (options);
  84.     return (ret);
  85. }
  86.